<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>分数线预测</title>
</head>
<body>
<h1>分数线预测</h1>
<label for="major">选择你的专业:</label>
<select id="major">
  <option value="电子信息">电子信息</option>
  <option value="工学">工学</option>
  <!-- 添加其他专业选项 -->
</select>
<button onclick="predictScores()">Predict Scores</button>
<div id="predictionResult"></div>

<script>
  function predictScores() {
    var selectedMajor = document.getElementById("major").value;
    var url = "/predict-scores?majorName=" + selectedMajor;

    fetch(url)
            .then(response => response.json())
            .then(data => {
              var resultElement = document.getElementById("predictionResult");
              resultElement.innerHTML = "<h2>Prediction Results:</h2>";
              data.forEach((score, index) => {
                resultElement.innerHTML += "<p>Year " + (2025 + index) + ": " + score.toFixed(2) + "</p>";
              });
            })
            .catch(error => console.error('Error:', error));
  }
</script>
</body>
</html>
